#include "MultiMedia.h"
#include "MultiMediaRegistry.h"
#include "Book.h"

using namespace std;

int main( )
{
	MultiMediaRegistry MMRegistry;

	MultiMedia* empty;

	std::vector<MultiMedia *> searchResults;

	MultiMedia* temp = new Book("Harry Potter", "JK", "fantasy", 1999, 680);
	MMRegistry.addEntry( temp );

	temp = new Book("Pelles vandring", "Kalle", "Barn", 2005, 150);
	MMRegistry.addEntry( temp );

	temp = new Book("aPelles vandring", "Kalle", "Barn", 2005, 150);
	MMRegistry.addEntry( temp );

	MMRegistry.writeRegistryToFile();

	MMRegistry.registry.clear();

	MMRegistry.readRegistryFromFile();

	cout << "The registry contains:" << endl;
	for( int i = 0; i < MMRegistry.registry.size(); i++ )
	{
		(*MMRegistry.registry[i]).Print( cout );
	}

	cout << "Sort the registry" << endl;
	MMRegistry.sortRegistry();

	cout << "The registry contains:" << endl;
	for( int i = 0; i < MMRegistry.registry.size(); i++ )
	{
		(*MMRegistry.registry[i]).Print( cout );
	}


	temp = new Book("Pelles vandring", "Kalle", "Barn", 2005, 150);
	MMRegistry.deleteEntry( temp );

	cout << "\nSearch for all books written by J.K. Rowling and printing them:" << endl;
	MMRegistry.searchMultiMediaString( searchResults, "Author", "JK" );
	for( int i = 0; i < searchResults.size(); i++ )
	{
		(searchResults[i])->Print( cout );
	}




	MMRegistry.writeRegistryToFile();

	cin.get();
	return 0;
}


